{% extends 'base.twig' %}
{% block style %}
    <link href="template/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" type="text/css">
    <script src="template/plugins/pnotify/js/pnotify.custom.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">

            <div class="row mt">
                <div class="col-lg-12">
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="active">
                            <a href="#home" data-toggle="tab">
                                货币列表
                            </a>
                        </li>
                        <li class="dropdown">
                            <a href="#" id="myTabDrop1" class="dropdown-toggle"
                               data-toggle="dropdown">功能
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu" role="menu" aria-labelledby="myTabDrop1">
                                <li><a href="javascript:void(0);" class="update">货币同步</a></li>
                            </ul>
                        </li>
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane fade in active" id="home">
                            <table class="table table-bordered ">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>货币名称</th>
                                    <th>货币简称</th>
                                    <th>前置货币符号</th>
                                    <th>后置货币符号</th>
                                    <th>更新时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for g in goodsList %}
                                   <tr>
                                       <td>{{ g.currency_id }}</td>
                                       <td>{{ g.currency_title }}</td>
                                       <td>{{ g.currency_code }}</td>
                                       <td>{% if g.symbol_left == null %} -- {% endif %}  {{ g.symbol_left }}</td>
                                       <td>{% if g.symbol_right == null %} -- {% endif %}{{ g.symbol_right }}</td>
                                       <td>{{ g.update_time }}</td>
                                   </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                            <div class="text-center">
                                {{ pageHtml|raw }}
                            </div>
                        </div>
                    </div>
                </div><!-- /col-lg-4 -->
            </div><!-- /row -->
        </section>
    </section>
    <script type="text/javascript">
        highlight_subnav('currency.php?');
        $(".update").click(function () {
            //弹出层
            
            $.post('currency.php?',{act:'update'}).success(function (data) {
                var ret = JSON.parse(data);
                if(!ret.ret)
                {
                    new PNotify({
                        title: '错误！！',
                        text: ret.msg,
                        type: 'error',
                        addclass: 'stack-bar-top'
                    });

                    return;
                }
                new PNotify({
                    title: '成功！',
                    text: ret.msg,
                    type: 'success',
                    addclass: 'stack-bar-top'
                });

                setTimeout(function () {
                    location.reload();
                },2000)

            });
        })
       
    </script>
{% endblock %}